home *** CD-ROM | disk | FTP | other *** search
/ PC Gamer (Italian) 30 / PC Gamer IT CD 30 1-2.iso / MOTS / GAMEDATA / EPISODE / JKM_PCG.GOO / cog_s1l2_doorswitch.cog < prev    next >
Text File  |  1998-02-25  |  4KB  |  165 lines

  1. # Jedi Knight Missions Cog Script
  2. #
  3. # S1L2_DOORSWITCH.COG
  4. #
  5. # [TL]
  6. #
  7. # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
  8. #
  9. #==========================================================
  10.  
  11. symbols
  12.  
  13. thing    door0                                linkid=1
  14. thing    sparkspot                nolink
  15. thing    player        local            nolink                    
  16.  
  17. surface    adjoin0                       linkid=2    
  18. surface    adjoin1                       linkid=3    
  19. surface    panel        mask=0x008        linkid=4
  20. surface    button          mask=0x008
  21.  
  22. sound    alarm
  23. sound    sparksound
  24. sound    kyle
  25. sound   kylelocked
  26. sound   wav0=lvrclik2.wav
  27.  
  28. sector    sector0                    linkid=5
  29. sector    sector1                    linkid=5
  30. sector    sector2                    linkid=5
  31. sector    sector3                    linkid=5
  32. sector    sector4                    linkid=5
  33. sector    sector5                    linkid=5
  34. sector    sector6                    linkid=5
  35. sector    sector7                    linkid=5
  36. sector    sector8                    linkid=5
  37. sector    sector9                    linkid=5
  38.  
  39. template        spark=+sparks            local
  40.  
  41. int     doorsector                           local
  42. int    soundnum0                local    
  43. int    soundnum1                    local
  44. int    soundnum2                   local
  45. int    burn=0                    local
  46. int    alarmon=0                local
  47. int     done=0                                  local
  48.  
  49. flex    minimumDelay=2.0
  50. flex    maximumDelay=4.0
  51. flex    nextSpark=0.5                              local
  52.  
  53. message startup
  54. message crossed
  55. message timer
  56. message damaged
  57. message activated
  58.  
  59. end
  60.  
  61. # ===================================================
  62. code
  63. startup:
  64.         MoveToFrame(door0, 1, 8);
  65.        doorsector = GetThingSector(door0);
  66.        SectorAdjoins(doorsector, 1);
  67.        SectorLight(doorsector, 1.0, 0.0); 
  68.        player=GetLocalPlayerThing();
  69.     return;
  70.  
  71. #....................................................
  72. activated:
  73.         if (GetCurFrame(door0) == 1) return;
  74.         
  75.         if (GetSenderId() == 1)
  76.         {
  77.                 if (done == 0)
  78.                 {
  79.                         done=1;
  80.                         SendMessageEx(GetMasterCOG(), user0, 1, 0, 0, 0);
  81.                         sleep(0.25);
  82.                         PlaySoundLocal(wav0, 1, 0, 0);
  83.                         sleep(0.25);
  84.                         PlaySoundLocal(kylelocked, 1, 0, 0);
  85.                 }
  86.                 else if (done == 1)
  87.                 {
  88.                         PlaySoundLocal(wav0, 1, 0, 0);
  89.                         sleep(0.25);
  90.                         PlaySoundLocal(kylelocked, 1, 0, 0);
  91.                 }        
  92.         
  93.         }
  94.         return;
  95.         
  96. crossed:
  97.     if (burn) return;
  98.         
  99.     if ((GetSenderId() == 2) && (alarmon == 0))
  100.         {
  101.                   soundnum0=PlaySoundLocal(alarm, 1, 0, 1);
  102.           MoveToFrame(door0, 0, 4);
  103.                   SectorAdjoins(doorsector, 0);
  104.         alarmon=1;
  105.     }
  106.         
  107.     if ((GetSenderId() == 3) && (alarmon == 1))
  108.     {
  109.          SetTimerEx(2, 0, 0, 0);
  110.     }
  111.     return;
  112.  
  113. #....................................................
  114. timer:
  115.         if (GetSenderID() == 0)
  116.         {
  117.             if (GetThingSector(player) == sector0) return;
  118.             if (GetThingSector(player) == sector1) return;
  119.             if (GetThingSector(player) == sector2) return;
  120.             if (GetThingSector(player) == sector3) return;
  121.             if (GetThingSector(player) == sector4) return;
  122.             if (GetThingSector(player) == sector5) return;
  123.             if (GetThingSector(player) == sector6) return;
  124.             if (GetThingSector(player) == sector7) return;
  125.             if (GetThingSector(player) == sector8) return;
  126.             if (GetThingSector(player) == sector9) return;
  127.         
  128.             MoveToFrame(door0, 1, 4);
  129.             SectorAdjoins(doorsector, 1);
  130.             StopSound(soundnum0, 0);
  131.             alarmon=0;
  132.         }
  133.         else
  134.         if (GetSenderID() == 1)
  135.         {
  136.                   CreateThing(spark, sparkspot);
  137.                  soundnum1=PlaySoundThing(sparksound, sparkspot, 1, -1, -1, 0);
  138.             
  139.                 nextSpark = minimumDelay + (Rand() * (maximumDelay - minimumDelay));
  140.             SetTimerEx(nextSpark, 1, 0, 0);
  141.         }
  142.     return;
  143.  
  144. #....................................................
  145. damaged:
  146.     if (burn) return;
  147.         
  148.     if (((GetSenderRef() == panel) || (GetSenderRef() == button)) && (alarmon == 0)) 
  149.     {
  150.         burn=1;    
  151.         SendMessageEx(GetMasterCOG(), user0, 2, 0, 0, 0);
  152.                 SetTimerEx(nextspark, 1, 0, 0);
  153.         SetWallCel(button, 1);
  154.         SetWallCel(panel, 1);
  155.                 
  156.                 sleep(1.5);
  157.         soundnum2=PlaySoundLocal(kyle, 1, 0, 0);
  158.                 jkPrintUNIString(-1, 60009);
  159.     }
  160.     return;
  161.         
  162. end
  163.  
  164.